package com.juben.svr.demos.web;

import com.juben.svr.domain.Conversations;
import com.juben.svr.service.MessageService;
import okhttp3.Request;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/message")
@CrossOrigin(origins = "http://localhost:5173",allowedHeaders = "*",allowCredentials = "true")
public class MessageController {
    @Autowired
    private MessageService messageService;
    @GetMapping("/getconversationByUID")
    public ResponseEntity<Conversations> getconversationByUID(@RequestParam int user1_id){
        System.out.println("getconversationByUID");
        System.out.println("前端传来的:"+user1_id);
        Conversations conversations = messageService.getconversationByUID(user1_id);
        System.out.println("conversations:"+conversations);
        return ResponseEntity.ok(conversations);
    }
}
